<template>
  <div id="layout">
    <el-container>
      <!-- 侧边栏导航 -->
      <el-aside width="250px" class="sidebar">
        <div class="logo">
          <el-icon><Sunny /></el-icon>
          <span>智慧农业3D</span>
        </div>
        <el-menu
          :default-active="$route.path"
          router
          class="sidebar-menu"
          background-color="#001529"
          text-color="#fff"
          active-text-color="#409EFF"
        >
          <el-menu-item index="/farm">
            <el-icon><View /></el-icon>
            <span>3D农场</span>
          </el-menu-item>
          <el-menu-item index="/dashboard">
            <el-icon><DataBoard /></el-icon>
            <span>数据看板</span>
          </el-menu-item>
          <el-menu-item index="/crops">
            <el-icon><Management /></el-icon>
            <span>作物管理</span>
          </el-menu-item>
          <el-menu-item index="/environment">
            <el-icon><Monitor /></el-icon>
            <span>环境监控</span>
          </el-menu-item>
          <el-menu-item index="/alerts">
            <el-icon><Warning /></el-icon>
            <span>智能预警中心</span>
          </el-menu-item>
          <el-menu-item index="/ai-plan">
            <el-icon><MagicStick /></el-icon>
            <span>AI种植推荐</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <!-- 主内容区 -->
      <el-container>
        <el-header class="header">
          <div class="header-left">
            <h2>{{ getPageTitle() }}</h2>
          </div>
          <div class="header-right">
            <el-button type="primary" size="small">
              <el-icon><Setting /></el-icon>
              系统设置
            </el-button>
          </div>
        </el-header>
        
        <el-main class="main-content">
          <router-view />
        </el-main>
        <el-footer class="footer">
          <span>© 2024 智慧农业企业级平台 | Powered by Vue 3 & Three.js</span>
        </el-footer>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'IndexLayout',
  methods: {
    getPageTitle() {
      const routeMap = {
        '/farm': '3D农场可视化',
        '/dashboard': '数据看板',
        '/crops': '作物管理',
        '/environment': '环境监控'
      }
      return routeMap[this.$route.path] || '智慧农业'
    }
  }
}
</script>

<style scoped>
#layout {
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.sidebar {
  background-color: #001529;
  color: white;
  height: 100%;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 6px rgba(0, 0, 0, 0.1);
}
.logo {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: bold;
  border-bottom: 1px solid #1f2937;
  color: #409EFF;
}
.logo .el-icon {
  margin-right: 8px;
  font-size: 24px;
}
.sidebar-menu {
  border: none;
}
.header {
  background: white;
  border-bottom: 1px solid #e4e7ed;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
.header-left h2 {
  margin: 0;
  color: #303133;
  font-weight: 600;
}
.main-content {
  background: #f5f7fa;
  padding: 20px;
  min-height: calc(100vh - 100px);
  margin-left: 250px;
}
.footer {
  background: #fff;
  color: #909399;
  text-align: center;
  padding: 12px 0;
  font-size: 14px;
  border-top: 1px solid #e4e7ed;
}
</style> 